﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using XStudio.XCRF.Data.Business.Archieve;
using XStudio.XCRF.Data.Business.Validate;

namespace XStudio.XCRF.Data.Entities
{
    /// <summary>
    /// CRF记录
    /// </summary>
    [CRFValidate()]
    public partial class CRF : BaseEntity<CRF>, IArchieve
    {
        #region 属性
        /// <summary>
        /// 患者ID
        /// </summary>
        [ForeignKey("Patient")]
        public Guid? PatientID { get; set; }
        /// <summary>
        /// 患者
        /// </summary>
        public virtual Patient Patient { get; set; }
        /// <summary>
        /// 医院编号
        /// </summary>
        [ArchieveField]
        [Column(TypeName = "varchar")]
        public string HospitalCode { get; set; }
        /// <summary>
        /// 患者病例编号
        /// </summary>
        [ArchieveField]
        [Column(TypeName = "varchar")]
        public string CrfCode { get; set; }
        /// <summary>
        /// 研究单位（医院）ID
        /// </summary>
        [ForeignKey("Hospital")]
        public Guid? HospitalID { get; set; }
        /// <summary>
        /// 研究单位
        /// </summary>
        [InverseProperty("CRFs")]
        public virtual Hospital Hospital { get; set; }
        /// <summary>
        /// 研究者ID
        /// </summary>
        [ForeignKey("Researcher")]
        public Guid? ResearcherID { get; set; }
        /// <summary>
        /// 研究者
        /// </summary>
        public Member Researcher { get; set; }
        /// <summary>
        /// 研究开始时间
        /// </summary>
        [ArchieveField]
        [DataType(DataType.Date)]
        [Column(TypeName = "date")]
        public DateTime? StartTime { get; set; }
        
        /// <summary>
        /// 基本信息（包含历史记录)
        /// </summary>
        [InverseProperty("CRF")]
        public virtual ICollection<BasicInfo.BasicInfo> BasicInfoes { get; set; }
        /// <summary>
        /// 实验室检查
        /// </summary>
        [InverseProperty("CRF")]
        public virtual ICollection<LabCheck.LabCheck> LabChecks { get; set; }
        /// <summary>
        /// 治疗信息
        /// </summary>
        [InverseProperty("CRF")]
        public virtual ICollection<CureInfo.CureInfo> CureInfoes { get; set; }
        #endregion 属性
    }
}
